package crivia.eca.am2.carry;

import java.util.List;

import crivia.c.a.KeyLink;
import crivia.c.carry.RelationKey;
import crivia.c.carry.SubCarry;
import crivia.c.exception.CarryIOFail;
import crivia.ecp.a.ECC;
import crivia.ecp.carry.ec.workflow.WFBase;
import crivia.src.CI;

public class ActionModel2Deploy extends ECC {
	
	static {
		if (!createTable(ActionModel2Deploy.class, true)){
			throw new CarryIOFail("Data Base Table Create Fail.");
		}
	}
	
	public static void main(String[] args) {
		CI.refreshDBI(ActionModel2Deploy.class);
		CI.refreshFields(ActionModel2Deploy.class);
	}

	@Override
	public String tableName() {
		return "Crivia_AM2_Deploy";
	}

	@Override
	public void keyLinks(List<KeyLink> keyLinks) {
		keyLinks.add(SubCarry.c2d("am2", ActionModel2.class));
		keyLinks.add(RelationKey.c2d("am2Name", "am2"
, ActionModel2.table(), ActionModel2.Keys.name, ActionModel2.pk()));
		keyLinks.add(SubCarry.c2d("wm", WorkflowModel.class));
		keyLinks.add(RelationKey.c2d("workflowName", "wm"
, WFBase.table(), WFBase.Keys.workflowName, WFBase.pk())
			.setRelationCDFormat("(select s."+WorkflowModel.Keys.workflowID
				+" from "+WorkflowModel.table()+" s"
				+" where s."+WorkflowModel.pk()+" = ?)")
		);
		keyLinks.add(RelationKey.c2d("workflowID", "wm"
, WorkflowModel.table(), WorkflowModel.Keys.workflowID, WorkflowModel.pk())
		);
	}


	
	//XXX DBI Begin.
	public enum Keys{
		am2("am2","am2")
		,am2Name("am2Name","name")
		,wm("wm","wm")
		,workflowName("workflowName","workflowName")
		,workflowID("workflowID","workflowID")
		;
		private String _dbKey;
		private String _key;
		Keys(String key,String dbKey){_key=key;_dbKey=dbKey;}
		@Override
		public String toString(){return _dbKey;}
		/**  <b>Key</b> in <b>Carry</b>. */
		public String key(){return _key;}
	}
	private static crivia.eca.am2.carry.ActionModel2Deploy dbi;
	public synchronized static void initDBI(){if(null!=dbi)return;dbi=new crivia.eca.am2.carry.ActionModel2Deploy();}
	/**  <b>DB Table</b> of <b>Carry</b>. */
	public static String table(){initDBI();return dbi.tableName();}
	/**  <b>Primary Key</b> of <b>Carry</b>. */
	public static String pk(){initDBI();return dbi.pk4db();}
	/**  <b>Relation SQL</b> of <b>Relation Key</b>. */
	public static String rSQL(crivia.eca.am2.carry.ActionModel2Deploy.Keys k,String t){initDBI();return dbi.relationSQL(k.key(),t);}
	//XXX DBI End.



	

	// XXX Fields Begin.



	/** ...(Miss Tip Text.) */
	private java.lang.String id;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getId(){
		return id;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setId(java.lang.String id){
		this.id = id;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private crivia.eca.am2.carry.ActionModel2 am2;
	/** Getter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2 getAm2(){
		if (null == am2){
			am2 = new crivia.eca.am2.carry.ActionModel2();
		}
		return am2;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setAm2(crivia.eca.am2.carry.ActionModel2 am2){
		this.am2 = am2;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String am2Name;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getAm2Name(){
		return am2Name;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setAm2Name(java.lang.String am2Name){
		this.am2Name = am2Name;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private crivia.eca.am2.carry.WorkflowModel wm;
	/** Getter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModel getWm(){
		if (null == wm){
			wm = new crivia.eca.am2.carry.WorkflowModel();
		}
		return wm;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setWm(crivia.eca.am2.carry.WorkflowModel wm){
		this.wm = wm;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String workflowName;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getWorkflowName(){
		return workflowName;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setWorkflowName(java.lang.String workflowName){
		this.workflowName = workflowName;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String workflowID;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getWorkflowID(){
		return workflowID;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.ActionModel2Deploy setWorkflowID(java.lang.String workflowID){
		this.workflowID = workflowID;
		return this;
	}


	// XXX Fields End.

}